﻿<UserControl
    x:Class="InputsExample.SquareControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:InputsExample"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:common="using:InputsExample.Common"
    mc:Ignorable="d"
    d:DesignHeight="128"
    d:DesignWidth="128"
    d:DataContext="{d:DesignInstance Type=local:SquareShapeModel, IsDesignTimeCreatable=True}">
    <UserControl.Resources>
        <common:BooleanToVisibilityConverter x:Key="IfTrueThenVisible"/>
    </UserControl.Resources>

    <Grid Width="{Binding Size}" Height="{Binding Size}" RenderTransformOrigin="0.5,0.5">
        <Grid.RenderTransform>
            <TransformGroup>
                <TranslateTransform X="{Binding LeftPos}" Y="{Binding TopPos}"/>
                <RotateTransform Angle="{Binding Rotation}" CenterX="{Binding LeftPos}" CenterY="{Binding TopPos}"/>
                <ScaleTransform ScaleX="{Binding Scale}" ScaleY="{Binding Scale}" CenterX="{Binding LeftPos}" CenterY="{Binding TopPos}"/>
            </TransformGroup>
        </Grid.RenderTransform>
        <!-- Content -->
        <Rectangle x:Name="InnerShape" 
                   ManipulationMode="{Binding ManipulationMode}"
                   IsTapEnabled="{Binding IsTapEnabled, Mode=TwoWay}"
                   IsRightTapEnabled="{Binding IsRightTapEnabled, Mode=TwoWay}"
                   IsDoubleTapEnabled="{Binding IsDoubleTapEnabled, Mode=TwoWay}"
                   IsHoldingEnabled="{Binding IsHoldingEnabled, Mode=TwoWay}">
            <Shape.Fill>
                <SolidColorBrush Color="{Binding Color}"/>
            </Shape.Fill>
        </Rectangle>
        
        <!-- Selection Outline -->
        <Rectangle StrokeThickness="3" Stroke="Black" Visibility="{Binding IsHot, Converter={StaticResource IfTrueThenVisible}}"/>
    </Grid>
</UserControl>
